package br.com.dips.service;

import java.util.List;
import java.util.Map;

import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.inject.Inject;

import br.com.dips.dao.OrganizacaoDAO;
import br.com.dips.enums.Situacao;
import br.com.dips.model.Organizacao;

@Stateless
public class OrganizacaoService {

	@Inject
	private OrganizacaoDAO dao;
	
	public Organizacao incluir(Organizacao org) {
		dao.incluir(org);
		return dao.consultar(org.getId());
	}
	
	public Organizacao alterar(Organizacao org) {
		dao.alterar(org);
		return dao.consultar(org.getId());
	}
	
	@TransactionAttribute(TransactionAttributeType.SUPPORTS)
	public Organizacao consultar(Integer id) {
		return dao.consultar(id);
	}
	
	@TransactionAttribute(TransactionAttributeType.SUPPORTS)
	public List<Organizacao> listar(int start, int pageSize, String sortField, String sortOrder, Map<String, String> filters) {
		return this.dao.listar(start, pageSize, sortField, sortOrder, filters);
	}
	
	@TransactionAttribute(TransactionAttributeType.SUPPORTS)
	public List<Organizacao> listarPorSituacao(Situacao situacao) {
		return this.dao.listarPorSituacao(situacao);
	}
	
	@TransactionAttribute(TransactionAttributeType.SUPPORTS)
	public List<Organizacao> listar() {
		return this.dao.listar();
	}
	
	@TransactionAttribute(TransactionAttributeType.SUPPORTS)
	public int conta(Map<String, String> filters) {
		return this.dao.conta(filters);
	}
}
